package com.swu.pad.util.ExcelUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CsvReader {

	public static List<Map<String, String>> readCsv(InputStream inputStream) throws IOException {
		InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
		BufferedReader bufferedreader = new BufferedReader(isr);
		List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
		String stemp;
		String[] header = { "学号", "姓名", "小组作业组号", "小组作业互评组号", "个人作业编号", "个人作业互评号", "邮箱" };
		if ((stemp = bufferedreader.readLine()) != null) {
			// header = stemp.split(",");
		}
		while ((stemp = bufferedreader.readLine()) != null) {
			String[] split = stemp.split(",");
			if (split == null)
				continue;
			Map<String, String> tempMap = new HashMap<String, String>();
			for (int i = 0; i < split.length; i++) {
				tempMap.put(header[i].trim(), split[i].trim());
			}
			resultList.add(tempMap);
		}
		return resultList;
	}
}
